package com.example.demo.rest;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.security.Principal;

/**
 * @author void
 * @date 2021/5/18 17:20
 * @desc
 */
@RestController
public class SimpleController {
    /**
     * 直接访问http://localhost:8080会重定向到默认生成的登录页
     * OAuth2User
     * OAuth2AccessTokenResponseClient实现了以code交换access_token的具体逻辑
     * OAuth2UserService
     * @param principal
     * @return
     */
    @GetMapping("/hello")
    public String hello(Principal principal){
        return "hello,"+principal.getName();
    }
}
